package ffm.database.wrappers;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;
import javax.naming.NamingException;
import ffm.database.wrappers.TomcatDSWrapper;


/**
 * Class extending the TomcatDSWrapper - this just adds the ability to read the properties from a file
 * Port is actually ignored though - need to modify the TomcatDSWrapper to use port...
 * 
 * @author bbest
 *
 */

public class DirectConnectionManager extends TomcatDSWrapper 
{

	public String m_sDBPort;
	
	public DirectConnectionManager() 
	{
	}
	
	
	public void Initialise(String sPropsName, boolean bPropsFile) throws NamingException, FileNotFoundException, IOException 
	{
		if ( !bPropsFile )
			super.Initialise(sPropsName);
		else
		{
			Properties cProperties = new Properties();
			cProperties.load(new FileInputStream(sPropsName));
			
			m_sUserName 		= cProperties.getProperty("db_user");
			m_sPassword 		= cProperties.getProperty("db_password");
			m_sDatabaseName		= cProperties.getProperty("db_name");
			m_sDBPort 			= cProperties.getProperty("db_port");
			m_sServer 			= cProperties.getProperty("db_host");
			
			m_bUseDirect = true;
		}
	}
	
	

}
